package com.huawei;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Description: HJ43 迷宫问题
 *
 * @author weiruibai.vendor
 * Date: 2022/8/23 16:01
 */
public class HJ43 {

    /**
     * 4 6
     * 0 0 1 1 1 1
     * 1 0 1 0 0 0
     * 1 0 0 0 1 0
     * 1 1 1 1 0 0
     * <p>
     * 6 6
     * 0 0 0 0 0 1
     * 1 1 1 1 0 0
     * 0 0 0 1 1 0
     * 0 1 0 0 0 0
     * 0 1 1 1 1 1
     * 0 0 0 0 0 0
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        /*int[][] maze = {
                {0, 1, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {0, 0, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {0, 0, 0, 1, 0}
        };
        maze = new int[][]{
                {0, 1, 0, 0, 0},
                {0, 1, 0, 1, 0},
                {0, 0, 0, 0, 1},
                {0, 1, 1, 1, 0,},
                {0, 0, 0, 0, 0}

        };
        maze = new int[][]{
                {0, 0, 0, 0, 0, 1},
                {1, 1, 1, 1, 0, 0},
                {0, 0, 0, 1, 1, 0},
                {0, 1, 0, 0, 0, 0},
                {0, 1, 1, 1, 1, 1},
                {0, 0, 0, 0, 0, 0}
        };*/
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] strs = reader.readLine().split(" ");
        int N = Integer.parseInt(strs[0]);
        int M = Integer.parseInt(strs[1]);
        int[][] arr = new int[N][M];
        for (int i = 0; i < N; i++) {
            strs = reader.readLine().split(" ");
            for (int j = 0; j < M; j++) {
                arr[i][j] = Integer.parseInt(strs[j]);
            }
        }
        List<String> list = new ArrayList<>();
        boolean[][] visited = new boolean[N][M];
        process(arr, 0, 0, visited, list);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    private static boolean finished = false;

    private static void process(int[][] arr, int i, int j, boolean[][] visited,
                                List<String> list) {
        if (i < 0 || i >= arr.length || j < 0 || j >= arr[0].length || arr[i][j] == 1) {
            return;
        }
        if (i == arr.length - 1 && j == arr[0].length - 1) {
            finished = true;
            return;
        }
        visited[i][j] = true;
        list.add("(" + i + "," + j + ")");
        // 上
        process(arr, i - 1, j, visited, list);
        if (finished) {
            return;
        }
        // 下
        process(arr, i + 1, j, visited, list);
        if (finished) {
            return;
        }
        // 左
        process(arr, i, j - 1, visited, list);
        if (finished) {
            return;
        }
        // 上
        process(arr, i, j + 1, visited, list);
        if (finished) {
            return;
        }
        list.remove(list.size() - 1);
        visited[i][j] = false;
    }
}
